//
//  AppUtility.m
//  iOSToolkit-OC
//
//  Created by Evan Xie on 8/3/15.
//  Copyright (c) 2015 Family Wings. All rights reserved.
//

#import "AppUtility.h"


@implementation AppUtility

+ (void)postNotificationOnMainThread:(NSString *)notificationName object:(id)object userInfo:(NSDictionary *)userInfo
{
    if (!notificationName) {
        NSLog(@"Notification name can not be nil.");
        return;
    }
    
    dispatch_async(dispatch_get_main_queue(), ^{
        [[NSNotificationCenter defaultCenter] postNotificationName:notificationName object:object userInfo:userInfo];
    });
}

+ (void)runBlockOnMainThread:(void (^)(void))block
{
    if (block == NULL) {
        return;
    }
    
    dispatch_async(dispatch_get_main_queue(), ^{
        block();
    });
}

@end
